<?php
App::uses('Model', 'Model');
class AppModel extends Model {
	
	function invalidate($field, $value = true){
		return parent::invalidate($field, __($value));
	}
	

/**
 * Checks that a string contains only integer or letters or space utf-8 chars are allowed
 *
 * Returns true if string contains only integer or letters or space utf-8 chars are allowed
 *
 * $check can be passed as an array: array('fieldName' => 'fieldValue');
 *
 * @param mixed $check Value to check
 * @return boolean Success
 * @access public
 */
	function alphaNumeric($check) {
		if(is_array($check)){
			$check = array_values($check);
			$check = $check[0];
		}
		
		$regex = '/^[\p{Ll}\p{Lt}\p{Lu}\p{Nd}\p{Zs}]+$/mu';
		
		if(preg_match($regex, $check)){
			return true;
		}
		else{
			return false;
		}
	}
	
/**
 * modell adatainak lekérdezése
 * @param int $id a keresett rekord azonosítója
 * @return array a rekord minden adata
 */
	function getRow($id){
		if($id){
			return($this->find('first', array(
				'conditions'	=>		array('id'	=>	$id),
				'recursive'		=>		-1
				)));
		}
		else
			return false;
	}

	
}
?>
